package quartz;

import java.util.Date;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;

public class Demo
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		Scheduler handsomeMan = new StdSchedulerFactory().getScheduler();

		// CallGirl.class 回调类
		JobDetail concerneGirl = new JobDetail("任务的名称", "group1", CallGirl.class);
		JobDetail tt = new JobDetail("任务的名称1", "group2", CallGirl.class);

		// 10 重复次数,2000L 周期
		SimpleTrigger momentTrigger = new SimpleTrigger("trigger1", "group1", new Date(), null, 10, 1000L);

		CronTrigger t = new CronTrigger("trigger2", "group2", "0 24 13 * * ? * ");

		// way 2
		// 若时间到,即使重复100000000次也没有用
		long startTime = System.currentTimeMillis();
		SimpleTrigger momentTrigger2 = new SimpleTrigger("trigger2", "group1");
		momentTrigger2.setStartTime(new Date(startTime));
		momentTrigger2.setEndTime(new Date(startTime + 6000L));
		momentTrigger2.setRepeatCount(10);
		momentTrigger2.setRepeatInterval(1000L);

		// 帅哥通过时刻Trigger来调度关心女友这个job
		handsomeMan.scheduleJob(concerneGirl, momentTrigger);
		handsomeMan.scheduleJob(tt, t);

		// 开始
		handsomeMan.start();
	}

}
